home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
comms
/
other
/
novia
/
src
/
api
/
novia_nrc_api.c
< prev
next >
Wrap
Text File
|
1999-12-06
|
6KB
|
264 lines
#include <time.h>
#include <devices/timer.h>
#include <pragma/timer_lib.h>
#include <clib/timer_protos.h>
#include <exec/types.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <devices/conunit.h>
#include <intuition/intuition.h>
#include <dos/dos.h>
#include <libraries/fifo.h>
#include <pragma/exec_lib.h>
#include <pragma/graphics_lib.h>
#include <pragma/dos_lib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <novia/novia_global.h>
#include <novia/novia_misc.h>
#include <novia/novia_funcs.h>
#include <novia/novia_gui.h>
#include <novia/novia_registers.h>
#include <pragma/noviasys_lib.h>
extern struct NRCServer *nrcserver;
extern struct Task *MainTask;
void OpenConference();
#define YELL 1
#define WHISPER 2
#define BBSCOMMAND 4
#define SIGNAL 8
void OpenConference()
{
struct PortData *cport=(PortData *)FindTask(NULL)->tc_UserData;
char buffer[80];
char quit=FALSE;
struct RCMessage *rcmsg=AllocVec(sizeof(RCMessage),MEMF_ANY|MEMF_CLEAR);
struct RCMessage2 *msg=NULL;
struct Room *room=NULL;
ULONG UserID=0;
UWORD RoomID=0;
ULONG users=0;
ULONG counter=0;
ULONG cmdid;
BOOL nostdcmd=TRUE;
struct MsgPort *myrcport=CreateMsgPort();
struct RoomUser *user=NULL;
ULONG sb_myrcport=0;
BOOL logoff_send=FALSE;
if (nrcserver && nrcserver->ServerOpen && myrcport)
{
sb_myrcport=1<<myrcport->mp_SigBit;
ioprintf("\nChecking authentication on NRC-Server.\n");
ioprintf("please wait and smoke a cigarette, this could take 2-3 microseconds ...\n");
rcmsg->msgtype=RCMSG_LOGIN;
rcmsg->flag_internal=TRUE;
rcmsg->data_len=0;
strcpy(rcmsg->FromName,cport->LocalUser.Handle);
if (SendRCMsg(myrcport, rcmsg))
{
while (counter<20 && !(msg=(RCMessage2 *)GetMsg(myrcport)))
{
Delay(5);
counter++;
}
if (msg)
{
if (msg->rcmsg.msgtype==RCMSG_LOGIN_REPLY_OK)
{
ioprintf("nrc login ok\n");
user=msg->rcmsg.user;
rcmsg->user=user;
rcmsg->user->cport=cport;
rcmsg->FromUser=msg->rcmsg.ToUser;
rcmsg->FromRoom=msg->rcmsg.ToRoom;
rcmsg->ToRoom=msg->rcmsg.ToRoom;
}
else
{
ioprintf("Can't open connection. connection aborted by server.\n");
quit=TRUE;
}
}
else
{
quit=TRUE;
ioprintf("Can't open connection. out of time.\n");
}
}
while (!quit)
{
if ((cport->ProgramClose | !cport->network.online | user->flag_quit))
{
if (!logoff_send)
{
rcmsg->data_len=0;
rcmsg->msgtype=RCMSG_LOGOFF;
SendRCMsg(myrcport, rcmsg);
logoff_send=TRUE;
}
else
Delay(5);
}
else
{
nostdcmd=TRUE;
switch (nrc_getline(rcmsg,buffer,80,sb_myrcport))
{
case BBSCOMMAND:
cmdid=GetCommandID(buffer);
switch (cmdid)
{
case CMD_QUIT:
user->flag_quit=TRUE;
nostdcmd=TRUE;
break;
case CMD_LIST:
ioprintf("Total users: %d, %d\n",nrcserver->users);
room=(Room *)nrcserver->roomlist->lh_Head;
while (room->ln_Succ)
{
ioprintf("RoomNo: %d, RoomName: %s, Users: %d\n",room->RoomID,room->RoomName,room->users);
room=room->ln_Succ;
}
nostdcmd=TRUE;
break;
case CMD_HELP:
nostdcmd=TRUE;
break;
}
if (nostdcmd)
{
if (*buffer=='R'|*buffer=='r')
{
LONG newroom;
StrToLong(buffer+1,&newroom);
if (newroom)
{
rcmsg->msgtype=RCMSG_CHANGEROOM;
rcmsg->flag_internal=TRUE;
rcmsg->data_len=0;
rcmsg->aptrdata=(APTR)newroom;
SendRCMsg(myrcport, rcmsg);
}
}
else
{
if (!StdCommand(cmdid) && strlen(buffer))
{
ioprintf("%s: Unknown command\n",buffer);
}
}
}
ClearMemQuick(buffer,80);
break;
}
}
while(msg=(RCMessage2 *)GetMsg(myrcport))
{
if (msg->msg.mn_ReplyPort==myrcport)
{
if (msg->rcmsg.msgtype==RCMSG_LOGOFF_OK)
{
quit=TRUE;
}
FreeVec(msg);
}
else
{
switch (msg->rcmsg.msgtype)
{
case RCMSG_TEXT:
if (msg->rcmsg.flag_sysmsg)
{
}
else
{
if (msg->rcmsg.flag_anonymous)
{
ioprintf("z5c7Anonymous:c3z0");
}
else
{
if (msg->rcmsg.FromName)
{
ioprintf("z4c7%s:c3z0",msg->rcmsg.FromName);
// if (msg->rcmsg.flag_realname)
// ioprintf("(%s)",msg->rcmsg.FromRealName);
}
else
{
ioprintf("z5c7Unknown:c3z0");
}
}
if (msg->rcmsg.ToName)
{
if (msg->rcmsg.flag_private)
{
ioprintf("(c1PRIVc3)");
}
else
{
ioprintf("(to %s)",msg->rcmsg.ToName);
// if (msg->rcmsg.flag_realname)
// ioprintf("(%s) ",msg->rcmsg.ToRealName);
}
}
if (msg->rcmsg.flag_broadcast)
ioprintf("(BROADCAST)");
}
ioprintf("c7%s\n",msg->rcmsg.data);
break;
case RCMSG_CHANGEROOM_OK:
user=msg->rcmsg.user;
rcmsg->user->cport=cport;
rcmsg->FromUser=msg->rcmsg.ToUser;
rcmsg->FromRoom=msg->rcmsg.ToRoom;
rcmsg->ToRoom=msg->rcmsg.ToRoom;
ioprintf("c7%s\n",msg->rcmsg.data);
break;
case RCMSG_CHANGEROOM_FAILAT:
ioprintf("c7%s\n",msg->rcmsg.data);
break;
}
ReplyMsg((Message *)msg);
}
}
if (*buffer=='/')
{
if (buffer[1]==81)
{
// quit=TRUE;
}
else
{
if (FindArg("WHO",&buffer[1]))
{
}
}
}
else
{
if (strlen(buffer))
{
SendRCText(myrcport,rcmsg,buffer);
}
}
}
}
/*** end ***/
if (rcmsg)
FreeVec(rcmsg);
if (myrcport)
DeleteMsgPort(myrcport);
}